<!DOCTYPE HTML>
<html lang="en">
<head>
<title>Trim() / LTrim() / RTrim() - Syntax &amp; Usage | AutoHotkey</title>
<meta name="description" content="The Trim, LTrim and RTrim functions trim characters from the beginning and/or end of a string." />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link href="../static/theme.css" rel="stylesheet" type="text/css" />
<script src="../static/content.js" type="text/javascript"></script>
</head>
<body>

<h1>Trim() / LTrim() / RTrim() <span class="ver">[AHK_L 31+]</span></h1>

<p>Trims characters from the beginning and/or end of a string.</p>

<pre class="Syntax">
Result :=  <span class="func">Trim</span>(String, OmitChars := " `t")
Result := <span class="func">LTrim</span>(String, OmitChars := " `t")
Result := <span class="func">RTrim</span>(String, OmitChars := " `t")
</pre>
<h2>Parameters</h2>
<dl>

  <dt>String</dt>
  <dd><p>Any string value or variable.  Numbers are not supported.</p></dd>

  <dt>OmitChars</dt>
  <dd><p>An optional list of characters (case sensitive) to exclude from the beginning and/or end of <em>String</em>.  If omitted, spaces and tabs will be removed.</p></dd>

</dl>

<h2>Examples</h2>
<div class="ex" id="ExBasic">
<p><a href="#ExBasic">#1</a></p>
<pre>text := "  text  "
MsgBox % "No trim:`t '" text "'"
    . "`nTrim:`t '" Trim(text) "'"
    . "`nLTrim:`t '" LTrim(text) "'"
    . "`nRTrim:`t '" RTrim(text) "'"
MsgBox % LTrim("00000123","0")</pre>
</div>

</body>
</html>
